home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRRPT.C < prev    next >
Text File  |  1993-01-04  |  768b  |  29 lines

  1.  
  2. /*  File   : strrpt.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 20 April 1984
  5.     Defines: strrpt()
  6.  
  7.     strrpt(dst, src, k) "RePeaTs" the string src into dst k times.  E.g.
  8.     strrpt(dst, "hack ", 2) will move "hack hack" to dst.  If k <= 0 it
  9.     does nothing.  The result is the number of characters moved, except
  10.     for the closing NUL.  src may be "" but may not of course be NullS.
  11. */
  12.  
  13. #include "strings.h"
  14.  
  15. int strrpt(dst, src, k)
  16.     register char *dst;
  17.     char *src;
  18.     int k;
  19.     {
  20.         char *save;
  21.  
  22.         for (save = dst; --k >= 0; --dst) {
  23.             register char *p;
  24.             for (p = src; *dst++ = *p++; ) ;
  25.         }
  26.         return dst-save;
  27.     }
  28.  
  29.